package com.example.xiaoshuo_yudu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.xiaoshuo_yudu.entity.entity.News;
import com.example.xiaoshuo_yudu.entity.entity.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 新闻信息表 Mapper 接口
 * </p>
 *
 * @author xusen
 * @since 2025-07-24
 */
@Mapper
public interface AdminMapper extends BaseMapper<Users> {
    @Select("SELECT * FROM users WHERE (username LIKE CONCAT('%',#{keyword},'%') OR email LIKE CONCAT('%',#{keyword},'%')) " +
            "ORDER BY user_id LIMIT #{offset}, #{pageSize}")
    List<Users> getUserPage(String keyword, Integer pageSize, Integer offset);
    
    @Select("SELECT COUNT(*) FROM users WHERE username LIKE CONCAT('%',#{keyword},'%') OR email LIKE CONCAT('%',#{keyword},'%')")
    int count(String keyword);
}